<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" placeholder="请输入员工姓名" id="d1">
<input type="text" placeholder="请输入员工工资" id="d2">
<input type="text" placeholder="请输入员工岗位" id="d3">
<button onclick="addEmp()">添加员工</button>
<hr>
<table border="1">
    <caption>员工表</caption>
    <tr>
        <td>姓名</td>
        <td>工资</td>
        <td>岗位</td>
    </tr>
</table>
<script>
    function addEmp(){
        var inputE1 = document.querySelector("#d1");
        var inputE2 = document.querySelector("#d2");
        var inputE3 = document.querySelector("#d3");
        let nameValue=inputE1.value;
        let salaryValue=inputE2.value;
        let jobValue=inputE3.value;
        var empTr = document.createElement('tr');
        var nameTd = document.createElement('td');
        var salaryTd = document.createElement('td');
        var jobTd = document.createElement('td');
        nameTd.innerHTML=nameValue;
        salaryTd.innerHTML=salaryValue;
        jobTd.innerHTML=jobValue;
        console.log(nameTd,salaryTd,jobTd)

        empTr.append(nameTd,salaryTd,jobTd)
        console.log(empTr)
        let table=document.querySelector('table');
        table.append(empTr)
        document.querySelector('#d1').value=""
        document.querySelector('#d2').value=""
        document.querySelector('#d3').value=""

    }

</script>
</body>
</html>